import xlrd

table1 = xlrd.open_workbook('各学校实际选科情况.xls')
table1 = table1.sheet_by_name('Sheet1')

table2 = xlrd.open_workbook('各个高中资源.xls')
table2 = table2.sheet_by_name('各个高中教师人数')

school = 1

t2Dict={'政治':1,'历史':2,'地理':3,'物理':4,'生物':5,'化学':6}
def getTeacher(sub): # 得到某科教师人数
    return int(table2.cell(school + 11, t2Dict[sub]).value)

shunxu=['物理','化学','生物','历史','地理','政治','总人数']
def classNameToSub(name):
    return (name[0:2],name[2:4],name[4:6])

def getClassType(i):
    return table1.cell(i,0).value

def getClassNum(i):
    return int(table1.cell(i, school).value)

subDict={'政治':[],'历史':[],'地理':[],'物理':[],'生物':[],'化学':[]}
allClass=[]
def appendToClaList(name):
    subList=classNameToSub(name)
    for sub in subList:
        subDict[sub].append([name, None]) # 第一个是班级name，第二个是任课老师
    allClass.append(name)

def findTeacher(sub,name): # 查某班某科的老师
    # subDict[sub][name]
    for claName,teacher in subDict[sub]:
        if claName==name:
            return teacher
